package 
{
	import flash.desktop.NativeApplication;
	import flash.events.Event;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.ui.Multitouch;
	import flash.ui.MultitouchInputMode;
	
	import com.greensock.events.LoaderEvent;
	import com.greensock.loading.LoaderMax;
	import com.greensock.loading.SWFLoader;
	import com.greensock.loading.XMLLoader;
	import com.greensock.TweenLite;
	import com.greensock.TweenMax;
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageDisplayState;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;
	import flash.system.LoaderContext;
	import iscript.gameFramework.GameLite.Game;
	import iscript.uiFramework.components.button.BaseButton;
	import iscript.uiFramework.event.ButtonEvent;
	import iscript.uiFramework.UIFramework;
	
	/**
	 * ...
	 * @author ramond
	 */
	public class Main extends Sprite 
	{
		public var  loader:LoaderMax
		public function Main():void 
		{
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			stage.addEventListener(Event.DEACTIVATE, deactivate);
			
			// touch or gesture?
			Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
			
			// entry point
			 var game:Game = new Game(stage);
				 
				 
				 
				 
			     LoaderMax.defaultContext =  new LoaderContext(false, stage.loaderInfo.applicationDomain);
			     loader = new LoaderMax();			
			     loader.append(new SWFLoader("UISKin.swf", { name:"UISKINSWF" } ));
			     loader.append(new XMLLoader("UIResourceSetting.xml", { name:"UISKINXML" } ));
		         loader.load()
			     loader.addEventListener(LoaderEvent.COMPLETE, _initializeUI);
		}
		
		private function deactivate(e:Event):void 
		{
			// auto-close
			NativeApplication.nativeApplication.exit();
		}
		
		
		private function _initializeUI(e:LoaderEvent):void 
		{
 
			var data:XML = XML(XMLLoader(loader.getLoader("UISKINXML")).content)
		    var  uiFramework:UIFramework = new UIFramework();
				 uiFramework.initialize(stage, data);

			var  layout:ButtonUITest = new ButtonUITest();
				 addChild(layout);
				 
				 

		}
		
	}
	
}